<?php
	$auth = Zend_Auth::getInstance()->setStorage(new Zend_Auth_Storage_Session('user'));
	$slider = '';

	// Quảng cáo ở giữa kế bên search
	if(count($this->adv3) > 0) {
		$slider .= '<div class="slideshow" data-transition="crossfade" data-loop="true" data-skip="false">';
		$slider .= '<ul class="carousel">';
		
		While (list($key, $val) = each($this->adv3)) {
			if ($auth->hasIdentity()) {
				$clickHandler = 'clickAdv(true, ' . $auth->getIdentity()->id . ', ' . $val->getPage_id() . ', ' . $val->getVi_tri() . ', "' . $val->getUrl() . '", '. $this->point3 .')';
			} else {
				$clickHandler = 'clickAdv(false, 0, 0, 0, "' . $val->getUrl() . '", 0)';
			}

			$slider .= '<li class="slide">';
			$slider .= $this->cmsAdvertisement($this->baseUrl(ADV_IMAGES_PATH . $val->getImage_url()), false, $clickHandler);
			$slider .= '</li>';
		}

		$slider .= '</ul>';
		$slider .= "</div>";
		$slider .= '<script type="text/javascript">';
		$slider .= '$(".slideshow").slides({hoverPause: true, speed: 600, autostop: false, auto: 4000});';
		$slider .= '</script>';
	}

	$layout = $this->cmsSearch('slider', '36%', $slider);
	echo $layout;
	$layout = $this->cmsSubmenu(); 
	echo $layout;
	
	$itemCountPerPage = $this->itemCountPerPage;
	$frm_sendmail = $this->form_sendmailtoposter;
?>
<div id="wrapcontent">
	<?php
		// Quảng cáo ở bên trái
		if(count($this->adv2) > 0) {
			echo "<div id='floating_banner_left'>";
			
			While (list($key, $val) = each($this->adv2)) {
				if ($auth->hasIdentity()) {
					$clickHandler = 'clickAdv(true, ' . $auth->getIdentity()->id . ', ' . $val->getPage_id() . ', ' . $val->getVi_tri() . ', "' . $val->getUrl() . '", '. $this->point2 .')';
				} else {
					$clickHandler = 'clickAdv(false, 0, 0, 0, "' . $val->getUrl() . '", 0)';
				}
					
				echo $this->cmsAdvertisement($this->baseUrl(ADV_IMAGES_PATH . $val->getImage_url()), false, $clickHandler);
			}
			
			echo "</div>";
		} 
	?>
	<div id="sidebar1">
		<?php
			$img = '<img src="' . $this->baseUrl(PUBLIC_PATH . "/img/icon/icon_hot.gif") . '" />';
			$block = $this->cmsBlock('Phòng trọ', $img, $this->itemsHotPtrTinTro); 
			echo $block;
			
			// Logo ở bên trái
			if(count($this->adv5) > 0) {
				echo "<div>";
					
				While (list($key, $val) = each($this->adv5)) {
					if ($auth->hasIdentity()) {
						$clickHandler = 'clickAdv(true, ' . $auth->getIdentity()->id . ', ' . $val->getPage_id() . ', ' . $val->getVi_tri() . ', "' . $val->getUrl() . '", '. $this->point5 .')';
					} else {
						$clickHandler = 'clickAdv(false, 0, 0, 0, "' . $val->getUrl() . '", 0)';
					}
						
					echo $this->cmsAdvertisement($this->baseUrl(ADV_IMAGES_PATH . $val->getImage_url()), false, $clickHandler);
				}
					
				echo "</div>";
			}
		?>
		<!-- Begin Block hỗ trợ trực tuyến -->
		<?php 
			$block = $this->cmsBlock('Hỗ trợ trực tuyến', '', $this->thong_tin_cty, 3); 
			echo $block;
		?>
		<!-- End Block hỗ trợ trực tuyến -->
		<!-- Begin Block thống kê truy cập -->
		<?php 
			$block = $this->cmsBlock('Thống kê truy cập', '', 'info', 4); 
			echo $block;
		?>
		<!-- End Block thống kê truy cập -->
		<div class="clear"></div>
	</div>
	<?php
		// Quảng cáo ở bên phải
		if(count($this->adv4) > 0) {
			echo "<div id='floating_banner_right'>";
		
			While (list($key, $val) = each($this->adv4)) {
				if ($auth->hasIdentity()) {
					$clickHandler = 'clickAdv(true, ' . $auth->getIdentity()->id . ', ' . $val->getPage_id() . ', ' . $val->getVi_tri() . ', "' . $val->getUrl() . '", '. $this->point4 .')';
				} else {
					$clickHandler = 'clickAdv(false, 0, 0, 0, "' . $val->getUrl() . '", 0)';
				}
					
				echo $this->cmsAdvertisement($this->baseUrl(ADV_IMAGES_PATH . $val->getImage_url()), false, $clickHandler);
			}
		
			echo "</div>";
		} 
	?>
	<div id="sidebar2">
		<div class="block">
			<div class="title">
				<span>Mạng xã hội</span>
			</div>
			<div class="content">
				<div class="follow">
					<div class="addthis_toolbox addthis_32x32_style addthis_vertical_style">
						<a class="addthis_button_facebook_follow" addthis:userid="kenhnhatro.vn"></a>
						<a class="addthis_button_twitter_follow" addthis:userid="kenh_nhatro"></a>
					</div>
				</div>
			</div>
			<br class="clear" />
		</div>
		<?php
			$img = '<img src="' . $this->baseUrl(PUBLIC_PATH . "/img/icon/icon_new.gif") . '" />';
			$block = $this->cmsBlock('Tin rao mới', $img, $this->itemsNewPtrTinTro); 
			echo $block;
			$img = '<img class="icon" src="' . $this->baseUrl(PUBLIC_PATH . "/img/icon/highlights.png") . '" />';
			$block = $this->cmsBlock('Tin tức nổi bật', $img, $this->itemsHotTinTuc, 2);
			echo $block;
			
			// Logo ở bên phải
			if(count($this->adv6) > 0) {
				echo "<div>";
			
				While (list($key, $val) = each($this->adv6)) {
					if ($auth->hasIdentity()) {
						$clickHandler = 'clickAdv(true, ' . $auth->getIdentity()->id . ', ' . $val->getPage_id() . ', ' . $val->getVi_tri() . ', "' . $val->getUrl() . '", '. $this->point6 .')';
					} else {
						$clickHandler = 'clickAdv(false, 0, 0, 0, "' . $val->getUrl() . '", 0)';
					}
						
					echo $this->cmsAdvertisement($this->baseUrl(ADV_IMAGES_PATH . $val->getImage_url()), false, $clickHandler);
				}
			
				echo "</div>";
			}
		?>
		<div id="adnet_widget_23221" style="display: none;"></div>
		<script type="text/javascript">var is_load_adnet_lib = is_load_adnet_lib || 1;if(is_load_adnet_lib == 1) {is_load_adnet_lib = 2;if(typeof(jQuery)=='undefined') {document.write(unescape("%3Cscript src='http://s0.adnet.vn/jquery.min.js' type='text/javascript'%3E%3C/script%3E"));}document.write(unescape("%3Cscript src='http://s0.adnet.vn/js/adnet34.js' type='text/javascript'%3E%3C/script%3E"));}</script><script type="text/javascript" src="http://widget.adnet.vn/js/js.php?widget_id=23221"></script>
		<div class="clear" style="margin: 5px"></div>
	</div>
	<div id="primary">
		<?php
			$html = '<div class="read_more"><a id="ptr" href="/ptrtinrao/index/loaitin/2">Xem tất cả</a></div>';
			$title = array(array('id' => 2, 'pane1' => 'Phòng cho thuê'), array('id' => 1, 'pane2' => 'Tìm phòng trọ'));
			
			// Hiển thị items VIP1 tìm người ở trọ của table Ptr_Tin_Rao
			$htmlVIPTNPtrTinTro = '';
			foreach ($this->itemsVIPTNPtrTinTro as $val) {
				$id_tin_rao	= $val->id;
				$tieu_de 	= $val->tieu_de;
				$img 		= $val->hinh_anh;
				$hinh_anh 	= '/phong_tro/avatar/' . $img;
				$luot_xem 	= $val->luot_xem;
				$ngay_dang 	= $val->ngay_dang;
				$dia_chi 	= $val->dia_chi;
				$gia_phong 	= number_format($val->gia_phong, 3, ",", ",") . ' VNĐ';
				if ($val->gia_phong == null || $val->gia_phong == 0)
					$gia_phong = 'Thỏa thuận';
				$dien_tich 	= $val->dien_tich;
				$con_phong 	= $val->con_phong;
				$quan_huyen	= $val->getQuanHuyenObj();
				$nguoi_dang = $val->getNguoiDangObj();
				$email 		= $nguoi_dang->email;
				if (preg_match("/(.*)[,](.*)/", $img)) {
					$list_image = explode (',', $img);
					$hinh_anh = '/phong_tro/avatar/' . $list_image[0];
				}
				$htmlVIPTNPtrTinTro .= '<div class="item">';
				$htmlVIPTNPtrTinTro .= '<div class="metadata">';
				$htmlVIPTNPtrTinTro .= '<img src="' . $this->baseUrl(PUBLIC_IMG_URL . $hinh_anh) . '" alt="' . $val->tieu_de . '" width="64px" height="64px" onerror="this.onerror=null; this.src=\'' . $this->baseUrl(PUBLIC_IMG_URL . '/phong_tro/avatar/error_avatar_home.png') . '\';" />';
				$htmlVIPTNPtrTinTro .= '<ul>';
				$htmlVIPTNPtrTinTro .= '<li class="label-view">Số lượt xem</li>';
				$htmlVIPTNPtrTinTro .= '<li class="num-view">' . $luot_xem . '</li>';
				$htmlVIPTNPtrTinTro .= '</ul>';
				$htmlVIPTNPtrTinTro .= '</div>';
				$htmlVIPTNPtrTinTro .= '<a title="' . $tieu_de . '" rel="bookmark" href="' . $this->baseUrl("/ptrtinrao/view/id/" . $id_tin_rao) . '">' . Zendhlt_Encode::truncateString_($tieu_de, 48). '</a>';
				$htmlVIPTNPtrTinTro .= '<div class="date post-date">' . $ngay_dang . '<div class="icon_vip"></div></div>';
				$htmlVIPTNPtrTinTro .= '<div class="info">';
				$htmlVIPTNPtrTinTro .= 'Địa chỉ: ' . $dia_chi . '<br />';
				$htmlVIPTNPtrTinTro .= 'Giá phòng: <span class="price">' . $gia_phong . '</span><br />';
				$htmlVIPTNPtrTinTro .= 'Diện tích: ' . $dien_tich . ' m<sup>2</sup><br />';
				$htmlVIPTNPtrTinTro .= '<div class="district">' . $quan_huyen->ten . '<br />';
				if ($con_phong)
					$htmlVIPTNPtrTinTro .= '<div class="icon_con_phong"></div>';
				$htmlVIPTNPtrTinTro .= '<a class="send_email" title="Gửi email đến người đăng" href="#sendMailModal" data-toggle="modal" onclick="setVal(\'ptrtinrao\', ' . $id_tin_rao . ', ' . $nguoi_dang->id . ', \'' . $nguoi_dang->email . '\')"><img src="' . $this->baseUrl(DEFAULT_PATH . '/img/icon_email.png') . '" alt="' . $email . '" /></a>';
				$htmlVIPTNPtrTinTro .= '</div>';
				$htmlVIPTNPtrTinTro .= '</div>';
				$htmlVIPTNPtrTinTro .= '<div class="clear"></div></div>';
			};
			if ($this->totalItemVIPTNPtrTinTro > $itemCountPerPage) {
				$htmlVIPTNPtrTinTro .= '<div class="pagenavi">';
				$htmlVIPTNPtrTinTro .= '<div id="VIPTNPtrTinTro" class="pagination">';
				$htmlVIPTNPtrTinTro .= $this->paginationControl($this->panigatorVIPTNPtrTinTro, 'Sliding', 'pagination.phtml', array('ajax' => "'#tab1_pane1', 'ptrtinrao', 2, "));
				$htmlVIPTNPtrTinTro .= '</div>';
				$htmlVIPTNPtrTinTro .= '<br class="clear" /></div>';
			}
			
			// Hiển thị items VIP1 tìm phòng trọ của table Ptr_Tin_Rao
			$htmlVIPTPtrPtrTinTro = '';
			foreach ($this->itemsVIPTPtrPtrTinTro as $val) {
				$id_tin_rao	= $val->id;
				$tieu_de 	= $val->tieu_de;
				$luot_xem 	= $val->luot_xem;
				$ngay_dang 	= $val->ngay_dang;
				$dia_chi 	= $val->dia_chi;
				$gia_phong 	= number_format($val->gia_phong, 3, ",", ",") . ' VNĐ';
				if ($val->gia_phong == null || $val->gia_phong == 0)
					$gia_phong = 'Thỏa thuận';
				$dien_tich 	= $val->dien_tich;
				$quan_huyen	= $val->getQuanHuyenObj();
				$nguoi_dang = $val->getNguoiDangObj();
				$email 		= $nguoi_dang->email;
				$htmlVIPTPtrPtrTinTro .= '<div class="item">';
				$htmlVIPTPtrPtrTinTro .= '<a title="' . $tieu_de . '" rel="bookmark" href="' . $this->baseUrl("/ptrtinrao/view/id/" . $id_tin_rao) . '">' . Zendhlt_Encode::truncateString_($tieu_de, 48). '</a>';
				$htmlVIPTPtrPtrTinTro .= '<div class="date"><span class="post-date">' . $ngay_dang . '</span>';
				$htmlVIPTPtrPtrTinTro .= '<span class="view"><b>' . $luot_xem . '</b> Lượt xem</span><div class="icon_vip"></div></div>';
				$htmlVIPTPtrPtrTinTro .= '<div class="info">';
				$htmlVIPTPtrPtrTinTro .= 'Địa chỉ: ' . $dia_chi . '<br />';
				$htmlVIPTPtrPtrTinTro .= 'Giá phòng: <span class="price">' . $gia_phong . '</span><br />';
				$htmlVIPTPtrPtrTinTro .= 'Diện tích: ' . $dien_tich . ' m<sup>2</sup><br />';
				$htmlVIPTPtrPtrTinTro .= '<div class="district">' . $quan_huyen->ten . '<br />';
				$htmlVIPTPtrPtrTinTro .= '<a class="send_email" title="Gửi email đến người đăng" href="#sendMailModal" data-toggle="modal" onclick="setVal(\'ptrtinrao\', ' . $id_tin_rao . ', ' . $nguoi_dang->id . ', \'' . $nguoi_dang->email . '\')"><img src="' . $this->baseUrl(DEFAULT_PATH . '/img/icon_email.png') . '" alt="' . $email . '" /></a>';
				$htmlVIPTPtrPtrTinTro .= '</div>';
				$htmlVIPTPtrPtrTinTro .= '</div>';
				$htmlVIPTPtrPtrTinTro .= '<div class="clear"></div></div>';
			}
			if ($this->totalItemVIPTPtrPtrTinTro > $itemCountPerPage) {
				$htmlVIPTPtrPtrTinTro .= '<div class="pagenavi">';
				$htmlVIPTPtrPtrTinTro .= '<div id="VIPTPtrPtrTinTro" class="pagination">';
				$htmlVIPTPtrPtrTinTro .= $this->paginationControl($this->panigatorVIPTPtrPtrTinTro, 'Sliding', 'pagination.phtml', array('ajax' => "'#tab1_pane2', 'ptrtinrao', 1, "));
				$htmlVIPTPtrPtrTinTro .= '</div>';
				$htmlVIPTPtrPtrTinTro .= '<br class="clear" /></div>';
			}
			
			$info = array('pane1' => $htmlVIPTNPtrTinTro, 'pane2' => $htmlVIPTPtrPtrTinTro);
			$block = $this->cmsBlockTabs($title, $html, $info, 'tab1', 'onclick="changeReadmore(this, \'#ptr\', \'ptrtinrao\');"'); 
			echo $block;
			
			$html = '<div class="read_more"><a id="ogh" href="/oghtinrao/index/loaitin/3">Xem tất cả</a></div>';
			$title = array(array('id' => 3, 'pane1' => 'Cần ở ghép'), array('id' => 4, 'pane2' => 'Tìm người ở ghép'));
			
			// Hiển thị items VIP1 cần ở ghép của table Ogh_Tin_Rao
			$htmlVIPCOGOghTinTro = '';
			foreach ($this->itemsVIPCOGOghTinTro as $val) {
				$id_tin_rao	= $val->id;
				$tieu_de 	= $val->tieu_de;
				$hinh_anh 	= '/phong_tro/avatar/' . $val->hinh_anh;
				$luot_xem 	= $val->luot_xem;
				$ngay_dang 	= $val->ngay_dang;
				$dia_chi 	= $val->dia_chi;
				$gia_phong 	= number_format($val->gia_o_ghep, 3, ",", ",") . ' VNĐ';
				if ($val->gia_o_ghep == null || $val->gia_o_ghep == 0)
					$gia_phong = 'Thỏa thuận';
				$dien_tich 	= $val->dien_tich_phong;
				$quan_huyen	= $val->getQuanHuyenObj();
				$nguoi_dang = $val->getNguoiDangObj();
				$email		= $nguoi_dang->email;
				$htmlVIPCOGOghTinTro .= '<div class="item">';
				$htmlVIPCOGOghTinTro .= '<div class="metadata">';
				$htmlVIPCOGOghTinTro .= '<img src="' . $this->baseUrl(PUBLIC_IMG_URL . $hinh_anh) . '" alt="' . $val->tieu_de . '" width="64px" height="64px" onerror="this.onerror=null; this.src=\'' . $this->baseUrl(PUBLIC_IMG_URL . '/phong_tro/avatar/error_avatar_home.png') . '\';" />';
				$htmlVIPCOGOghTinTro .= '<ul>';
				$htmlVIPCOGOghTinTro .= '<li class="label-view">Số lượt xem</li>';
				$htmlVIPCOGOghTinTro .= '<li class="num-view">' . $luot_xem . '</li>';
				$htmlVIPCOGOghTinTro .= '</ul>';
				$htmlVIPCOGOghTinTro .= '</div>';
				$htmlVIPCOGOghTinTro .= '<a title="' . $tieu_de . '" rel="bookmark" href="' . $this->baseUrl("/oghtinrao/view/id/" . $id_tin_rao) . '">' . Zendhlt_Encode::truncateString_($tieu_de, 48). '</a>';
				$htmlVIPCOGOghTinTro .= '<div class="date post-date">' . $ngay_dang . '<div class="icon_vip"></div></div>';
				$htmlVIPCOGOghTinTro .= '<div class="info">';
				$htmlVIPCOGOghTinTro .= 'Địa chỉ: ' . $dia_chi . '<br />';
				$htmlVIPCOGOghTinTro .= 'Giá phòng: <span class="price">' . $gia_phong . '</span><br />';
				$htmlVIPCOGOghTinTro .= 'Diện tích: ' . $dien_tich . ' m<sup>2</sup><br />';
				$htmlVIPCOGOghTinTro .= '<div class="district">' . $quan_huyen->ten . '<br />';
				$htmlVIPCOGOghTinTro .= '<a class="send_email" title="Gửi email đến người đăng" href="#sendMailModal" data-toggle="modal" onclick="setVal(\'oghtinrao\', ' . $id_tin_rao . ', ' . $nguoi_dang->id . ', \'' . $nguoi_dang->email . '\')"><img src="' . $this->baseUrl(DEFAULT_PATH . '/img/icon_email.png') . '" alt="' . $email . '" /></a>';
				$htmlVIPCOGOghTinTro .= '</div>';
				$htmlVIPCOGOghTinTro .= '</div>';
				$htmlVIPCOGOghTinTro .= '<div class="clear"></div></div>';
			};
			if ($this->totalItemVIPCOGOghTinTro > $itemCountPerPage) {
				$htmlVIPCOGOghTinTro .= '<div class="pagenavi">';
				$htmlVIPCOGOghTinTro .= '<div id="VIPCOGOghTinTro" class="pagination">';
				$htmlVIPCOGOghTinTro .= $this->paginationControl($this->panigatorVIPCOGOghTinTro, 'Sliding', 'pagination.phtml', array('ajax' => "'#tab2_pane1', 'oghtinrao', 3, "));
				$htmlVIPCOGOghTinTro .= '</div>';
				$htmlVIPCOGOghTinTro .= '<br class="clear" /></div>';
			}
			
			// Hiển thị items VIP1 tìm người ở ghép của table Ogh_Tin_Rao
			$htmlVIPTNOGOghTinTro = '';
			foreach ($this->itemsVIPTNOGOghTinTro as $val) {
				$id_tin_rao	= $val->id;
				$tieu_de 	= $val->tieu_de;
				$hinh_anh	= '/phong_tro/avatar/' . $val->hinh_anh;
				$luot_xem 	= $val->luot_xem;
				$ngay_dang 	= $val->ngay_dang;
				$dia_chi 	= $val->dia_chi;
				$gia_phong 	= number_format($val->gia_o_ghep, 3, ",", ",") . ' VNĐ';
				if ($val->gia_o_ghep == null || $val->gia_o_ghep == 0)
					$gia_phong = 'Thỏa thuận';
				$dien_tich 	= $val->dien_tich_phong;
				$quan_huyen	= $val->getQuanHuyenObj();
				$nguoi_dang = $val->getNguoiDangObj();
				$email 		= $nguoi_dang->email;
				$htmlVIPTNOGOghTinTro .= '<div class="item">';
				$htmlVIPTNOGOghTinTro .= '<div class="metadata">';
				$htmlVIPTNOGOghTinTro .= '<img src="' . $this->baseUrl(PUBLIC_IMG_URL . $hinh_anh) . '" alt="' . $val->tieu_de . '" width="64px" height="64px" onerror="this.onerror=null; this.src=\'' . $this->baseUrl(PUBLIC_IMG_URL . '/phong_tro/avatar/error_avatar_home.png') . '\';" />';
				$htmlVIPTNOGOghTinTro .= '<ul>';
				$htmlVIPTNOGOghTinTro .= '<li class="label-view">Số lượt xem</li>';
				$htmlVIPTNOGOghTinTro .= '<li class="num-view">' . $luot_xem . '</li>';
				$htmlVIPTNOGOghTinTro .= '</ul>';
				$htmlVIPTNOGOghTinTro .= '</div>';
				$htmlVIPTNOGOghTinTro .= '<a title="' . $tieu_de . '" rel="bookmark" href="' . $this->baseUrl("/oghtinrao/view/id/" . $id_tin_rao) . '">' . Zendhlt_Encode::truncateString_($tieu_de, 48). '</a>';
				$htmlVIPTNOGOghTinTro .= '<div class="date post-date">' . $ngay_dang . '<div class="icon_vip"></div></div>';
				$htmlVIPTNOGOghTinTro .= '<div class="info">';
				$htmlVIPTNOGOghTinTro .= 'Địa chỉ: ' . $dia_chi . '<br />';
				$htmlVIPTNOGOghTinTro .= 'Giá phòng: <span class="price">' . $gia_phong . '</span><br />';
				$htmlVIPTNOGOghTinTro .= 'Diện tích: ' . $dien_tich . ' m<sup>2</sup><br />';
				$htmlVIPTNOGOghTinTro .= '<div class="district">' . $quan_huyen->ten . '<br />';
				$htmlVIPTNOGOghTinTro .= '<a class="send_email" title="Gửi email đến người đăng" href="#sendMailModal" data-toggle="modal" onclick="setVal(\'oghtinrao\', ' . $id_tin_rao . ', ' . $nguoi_dang->id . ', \'' . $nguoi_dang->email . '\')"><img src="' . $this->baseUrl(DEFAULT_PATH . '/img/icon_email.png') . '" alt="' . $email . '" /></a>';
				$htmlVIPTNOGOghTinTro .= '</div>';
				$htmlVIPTNOGOghTinTro .= '</div>';
				$htmlVIPTNOGOghTinTro .= '<div class="clear"></div></div>';
			}
			if ($this->totalItemVIPCOGOghTinTro > $itemCountPerPage) {
				$htmlVIPTNOGOghTinTro .= '<div class="pagenavi">';
				$htmlVIPTNOGOghTinTro .= '<div id="VIPTNOGOghTinTro" class="pagination">';
				$htmlVIPTNOGOghTinTro .= $this->paginationControl($this->panigatorVIPTNOGOghTinTro, 'Sliding', 'pagination.phtml', array('ajax' => "'#tab2_pane2', 'oghtinrao', 4, "));
				$htmlVIPTNOGOghTinTro .= '</div>';
				$htmlVIPTNOGOghTinTro .= '<br class="clear" /></div>';
			}
			
			$info = array('pane1' => $htmlVIPCOGOghTinTro, 'pane2' => $htmlVIPTNOGOghTinTro);
			$block = $this->cmsBlockTabs($title, $html, $info, 'tab2', 'onclick="changeReadmore(this, \'#ogh\', \'oghtinrao\');"'); 
			echo $block;
		?>
	</div>
	<!-- SEND MAIL CHO NGUOI DANG MODAL -->
	<div id="sendMailModal" class="modal hide fade" tabindex="-1"
		role="dialog" aria-labelledby="sendMailModalLabel" aria-hidden="true">
		<div class="modal-header">
			<button type="button" class="close" data-dismiss="modal"
				aria-hidden="true">×</button>
			<h3 id="sendMailModalLabel">Gửi cho người đăng tin</h3>
		</div>
		<div class="modal-body">
			<?php if ($this->state_login) {?>
			<div id="sendmailalert" class="alert"></div>
			<form class="form-horizontal">
				<?php 
					echo $frm_sendmail->loai_bai_dang;
					echo $frm_sendmail->id_bai_dang;
					echo $frm_sendmail->id_nguoi_dang;
					echo $frm_sendmail->email_nguoi_dang;
				?>
				<div class="control-group">
					<label class="control-label" for="nguoi_gui">Tên của bạn</label>
					<div class="controls">
					<?php echo $frm_sendmail->nguoi_gui;?>
					</div>
				</div>
				<div class="control-group">
					<label class="control-label" for="email_nguoi_gui">Email của bạn</label>
					<div class="controls">
					<?php echo $frm_sendmail->email_nguoi_gui;?>
					</div>
				</div>
				<div class="control-group">
					<label class="control-label" for="subject">Tiêu đề (Subject)</label>
					<div class="controls">
					<?php echo $frm_sendmail->subject;?>
					</div>
				</div>
				<div class="control-group">
					<label class="control-label" for="message">Thông điệp (Message)</label>
					<div class="controls">
						<?php echo $frm_sendmail->message;?>
					</div>
				</div>
			</form>
			<?php } else {?>
			<p class="errors">Phải đăng nhập mới có thể thực hiện thao tác này.</p>
			<?php } ?>
		</div>
		<div class="modal-footer">
			<button class="btn" data-dismiss="modal" aria-hidden="true">Bỏ qua</button>
			<?php if ($this->state_login) {?>
			<button id="btnSendMail" class="btn btn-primary">Gửi</button>
			<?php } else { ?>
			<a class="btn btn-primary" onclick="loginbtnClick()" data-dismiss="modal">Đăng nhập</a>
			<?php } ?>
		</div>
	</div>
	<script type="text/javascript">
		//Catch keydown event of the enter key
		$('#sendMailModal').keydown(function (e) {
			if(e.keyCode == 13) {
				sendForFriendProcess(e);
			}
		});
		//Catch click event of the send mail button
		$('#btnSendMail').click(function(e) {
			sendMailProcess(e);
		});
		
		$('#sendmail').click(function() {
			$('#sendmailalert').hide();
		});
		
		//Show the modal event processing
		$('#sendMailModal').on('show', function () {
			$(this).find('.alert').hide();
			$(this).find("input").each(function() {
				var inputid = $(this).attr('id');
				$("#"+inputid).parent().find('.errors').remove();
				$("#"+inputid+'[type="text"]').val("");
		    });
			$(this).find("textarea").each(function() {
				var inputid = $(this).attr('id');
				$("#"+inputid).val("");
		    });
		});
		
		$(function(){
			$('#sendMailModal').find("input").each(function() {
		        var inputid = $(this).attr('id');
		        $("#"+inputid).blur(function() {
		        	if(doValidation('sendMailModal', inputid, '/ajax/validatesendmail', null))
		        		$("#btnSendMail").removeAttr("disabled");
		        	else
		        		$("#btnSendMail").attr("disabled", "disabled");	
		        });
		    });
		});
		//Process send mail function
		function sendMailProcess(event) {
			var url = '/ajax/sendmail';
			var $this = $(this);
			var postData = $("#sendMailModal form").serializeObject();
			postData.format = "json";
			var isValid = true;
			$('#sendMailModal').find("input").each(function() {
				var inputid = $(this).attr('id');
				isValid = isValid&&doValidation('sendMailModal', inputid, '/ajax/validatesendmail', 'validate');
		    });
			if(isValid){
				$("#btnSendMail").attr("disabled", "disabled");
				$.ajax({
		            type: 'POST',
		            url: url,
		            async: true,
		            cache: true,
		            data: postData,
		            dataType: postData.format,
		            success: function(data){
		            	if(data.result) {
	                		$('#sendmailalert').html(data.message);
	                		$('#sendmailalert').show();
		            		setTimeout(function() {
								$('#sendMailModal').modal('hide'); 
							}, 1000);
		            	} else {
		            		if(data.message){
		                		$('#sendmailalert').html(data.message);
		                		$('#sendmailalert').show();
		                    }
		                }
		            }
		        });
				$("#btnSendMail").removeAttr("disabled");
			}
		}

		function setVal (loai, id, ndang, endang) {
			$('#loai_bai_dang').val(loai);
			$('#id_bai_dang').val(id);
			$('#id_nguoi_dang').val(ndang);
			$('#email_nguoi_dang').val(endang);
		}
	</script>
   	<div class="clear"></div>
   	<div id="adnet_widget_23220" style="display: none;"></div>
   	<script type="text/javascript">var is_load_adnet_lib = is_load_adnet_lib || 1;if(is_load_adnet_lib == 1) {is_load_adnet_lib = 2;if(typeof(jQuery)=='undefined') {document.write(unescape("%3Cscript src='http://s0.adnet.vn/jquery.min.js' type='text/javascript'%3E%3C/script%3E"));}document.write(unescape("%3Cscript src='http://s0.adnet.vn/js/adnet34.js' type='text/javascript'%3E%3C/script%3E"));}</script>
   	<script type="text/javascript" src="http://widget.adnet.vn/js/js.php?widget_id=23220"></script>
</div>